package com.example.juc_learn.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;


public class ThreadPoolUtil {

    static Logger logger = LoggerFactory.getLogger(ThreadPoolUtil.class);

    static int corePoolSize = 6;
    static int maximumPoolSize = 6;
    static long keepAliveTime = 60;
    static TimeUnit timeUnit = TimeUnit.SECONDS;
    static ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue(20);
    static ExecutorService service = new ThreadPoolExecutor(corePoolSize,maximumPoolSize,
            keepAliveTime,timeUnit,workQueue);

    public static void excute(Runnable command) {
         if(command == null) {
             logger.error("任务为空");
         }
         service.execute(command);
    }
}
